package com.itheima.tlias.mapper;


import com.github.pagehelper.Page;
import com.itheima.tlias.dto.EmpListDto;
import com.itheima.tlias.dto.LoginDto;
import com.itheima.tlias.entity.Emp;
import com.itheima.tlias.vo.EmpListVo;
import com.itheima.tlias.vo.EmpVo;
import com.itheima.tlias.vo.NameValueVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


@Mapper
public interface EmpMapper {
 /*    @Select(" SELECT e.*,d.name deptName FROM emp e LEFT JOIN dept d ON e.dept_id=d.id")
     List<EmpListVo> empPage(Integer page,Integer pageSize) throws Exception;
     Long sumEmp();*/

    //插件返回 Page对象
    Page<EmpListVo> empPage(EmpListDto dto);

    void addEmp(Emp emp);

    void deleteByIds(List<Integer> ids);

    EmpVo getById(Integer id);

    void updateEmp(Emp emp);

    @Select("select * from emp where username=#{userName}")
    Emp getByEmpUserName(String userName);

    @Select("select * from emp where phone=#{phone}")
    Emp getByEmpPhone(String phone);

    List<NameValueVo> empJobData();

    List<NameValueVo> empGenderData();

    @Select("select * from emp ")/*where job=1*/
    List<Emp> empListByJob();

    @Select("select * from emp where dept_id=#{id}")
    List<Emp> empByDeptId(Integer id);

    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp login(LoginDto dto);

    @Update("update emp set password=#{newpassword} where id=#{id}")
    void amendPassword(@Param("newpassword") String newpassword, @Param("id") Integer id);
}
